import re
from SimpylScrape.Parsers import SiteParser
import SimpylScrape.ParseUtils as Utils
from WootComments import WootComments

class Woot(SiteParser):
    """
    http://www.woot.com
    """

    product = ".//div[@class='productDescription']/h2[1]/text()"
    image = ".//div[@class='leadIn']//img[1]/@src"
    price = (".//div[@class='productDescription']/h3[@class='price']", Utils.dollars)
    shipping = (".//ul[@id='shippingOptions']/li", Utils.dollars)

    comments = (".//div[@class='module qualityPosts']"\
                    "//li[@class='comments']/a[1]/@href", WootComments)

if __name__ == '__main__':

    # Instantiates parser and runs it.
    w = Woot()()
    output = file('woot.xml', 'w+')

    # Write results as XML to file.
    w.toXML(output)
    output.close()

    # Truncated Version
    # Woot()().toXML(file('woot.xml', 'w+'))
